// pages/payList/payList.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
    currentIndex: 0,
    height: "",
    munStyle: ['bor', '', ''],
    img1:"../../images/pay/life1.png",
    img2:"../../images/pay/car.png",
    searchContent: "",
    list:undefined,
    numm: 1,
   
    

},
onLoad: function (options) {
    this.setData({
        list: [{
            id: 0,
            estate: '世纪佳园',//小区
            unit:8,
            floor: 808,
            phone: "139****0831",
            year:2021,
            mouth:"05",
            date:20,
            cost: 150.9,
            state: "待缴费"
          }, {
            id: 1,
            estate: '世纪佳园',//小区
            unit:8,
            floor: 808,
            phone: "139****0831",
            year:2021,
            mouth:"04",
            date:20,
            cost: 150.9,
            state: "已缴费"
      
          },{
            id: 2,
            estate: '世纪佳园',//小区
            unit:8,
            floor: 808,
            phone: "139****0831",
            year:2021,
            mouth:"03",
            date:20,
            cost: 150.9,
            state: "已缴费"
      
            }
            ,{
                id: 3,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"02",
                date:20,
                cost: 150.9,
                state: "已缴费"
          
                }
                ,{
                    id: 4,
                    estate: '世纪佳园',//小区
                    unit:8,
                    floor: 808,
                    phone: "139****0831",
                    year:2021,
                    mouth:"01",
                    date:20,
                    cost: 150.9,
                    state: "已缴费"
              
                    }
                    ,{
                        id: 5,
                        estate: '世纪佳园',//小区
                        unit:8,
                        floor: 808,
                        phone: "139****0831",
                        year:2020,
                        mouth:"12",
                        date:20,
                        cost: 150.9,
                        state: "已缴费"
                  
                        }],
    })

},

    click: function (e) { 
        console.log("按了：", e.currentTarget.id)
      },
    //用户点击tab时调用
  titleClick: function (e) {
    let currentPageIndex =
      this.setData({
        //拿到当前索引并动态改变
        currentIndex: e.currentTarget.dataset.idx
      })

  },



  /**
     * 点击键盘上的搜索
     */
    bindconfirm: function (e) {
        console.log("搜索内容 " + this.data.searchContent)
    },
 
    /**
     * 点击菜单操作
     */
    getContentData1: function () {
        this.setData({
            numm: 1,
            list: [{
                id: 0,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"05",
                date:20,
                cost: 150.9,
                state: "待缴费"
              }, {
                id: 1,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"04",
                date:20,
                cost: 150.9,
                state: "已缴费"
          
              },{
                id: 2,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"03",
                date:20,
                cost: 150.9,
                state: "已缴费"
          
                }
                ,{
                    id: 3,
                    estate: '世纪佳园',//小区
                    unit:8,
                    floor: 808,
                    phone: "139****0831",
                    year:2021,
                    mouth:"02",
                    date:20,
                    cost: 150.9,
                    state: "已缴费"
              
                    }
                    ,{
                        id: 4,
                        estate: '世纪佳园',//小区
                        unit:8,
                        floor: 808,
                        phone: "139****0831",
                        year:2021,
                        mouth:"01",
                        date:20,
                        cost: 150.9,
                        state: "已缴费"
                  
                        }
                        ,{
                            id: 5,
                            estate: '世纪佳园',//小区
                            unit:8,
                            floor: 808,
                            phone: "139****0831",
                            year:2020,
                            mouth:"12",
                            date:20,
                            cost: 150.9,
                            state: "已缴费"
                      
                            }],
        })
        console.log("点击了菜单") // 发送请求获取数据
    },

    getContentData2: function () {
        this.setData({
            numm: 2,
            list: [{
                id: 0,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"05",
                date:20,
                cost: 150.9,
                state: "待缴费"
                }, 
                {
                id: 1,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"04",
                date:20,
                cost: 150.9,
                state: "已缴费"
                          
                },{
                id: 2,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"03",
                date:20,
                cost: 150.9,
                state: "已缴费"
                          
                }
                ,{
                id: 3,
                estate: '世纪佳园',//小区
                unit:8,
                floor: 808,
                phone: "139****0831",
                year:2021,
                mouth:"02",
                date:20,
                cost: 150.9,
                state: "已缴费"
                              
                }]
        })
        console.log("点击了菜单") // 发送请求获取数据
    },
 
 
    /**
     * 点击头部tab选项卡
     */
    clickMun: function (e) {
        var mun = e.currentTarget.dataset.num;
        console.log(mun);
 
        var munStyleList = this.data.munStyle;
        for (let index in munStyleList) {
            if ((mun - 1) == index) {
                munStyleList[index] = 'bor';
                
            }
            
            else{
                munStyleList[index] = '';
            } 
        }
        this.setData({
            munStyle: munStyleList,
        })
 
        switch (mun) {
            case '1':
                this.setData({
                    img1: "../../images/pay/life1.png",
                    img2: "../../images/pay/car.png"
                })
                this.getContentData1();
                break;
            case '2':
                this.setData({
                    img1: "../../images/pay/life.png",
                    img2: "../../images/pay/car1.png"
                })
                this.getContentData2();
                break;
            default:
                console.log('菜单不存在');
        }
    },
 
 
 
    /**
     * 设置内容区域高度自适应
     */
    setHeightContent: function () {
        var that = this
        var query = wx.createSelectorQuery()
        query.select('.header').boundingClientRect(function (res) { // 获取头部view的高度
            var resHeight = res.height
            wx.getSystemInfo({ // 获取网页高度
                success: function (res) {
                    let windowHeight = (res.windowHeight * (750 / res.windowWidth));
                    resHeight = (resHeight * (750 / res.windowWidth));
                    console.log("屏幕高度可用:" + windowHeight + "rpx");
                    console.log("内容区域可用高度" + (windowHeight - resHeight) + "rpx")
                    console.log("内容区域距离顶部高度" + resHeight + "rpx")
 
                    that.setData({
                        height: windowHeight - resHeight //网页高度 - 头部高度
                    })
                }
            })
        }).exec();
    },
  

    /**
   * 生命周期函数--监听页面加载
   */


  
})